#!ipxe

goto ${menu} ||

:live_menu
set os elementary OS
menu ${os} - Current Arch [ ${arch} ]
iseq ${arch} x86_64 && set arch_a amd64 || set arch_a ${arch}
item --gap ${os} Versions
item elementaryos-5-default-squash ${space} ${os} 5
choose live_version || goto live_exit
goto ${live_version}

{% for key, value in endpoints.items() | sort %}
{% if value.os == "elementary-os" and 'squash' in key %}
{% set kernel_name = value.kernel %}
:{{ key }}
set squash_url ${live_endpoint}{{ value.path }}filesystem.squashfs
{% for key, value in endpoints.items() | sort %}
{% if key == kernel_name %}
set kernel_url ${live_endpoint}{{ value.path }}
{% endif %}
{% endfor %}
goto boot
{% endif %}
{% endfor %}

:boot
imgfree
kernel ${kernel_url}vmlinuz ip=dhcp boot=casper maybe-ubiquity netboot=http fetch=${squash_url} initrd=initrd ${cmdline}
initrd ${kernel_url}initrd
boot

:live_exit
clear menu
exit 0
